<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue'
import stiticCom from "@/components/stiticCom.vue";
import Field from "@/components/Field.vue";
import Calcult from "@/components/Calcult.vue";
import MHistory from "@/components/MHistory.vue";


const tabList = ref([
    {
        name: "Statistics"
    },
    {
        name: "Field level Alarm(18)"
    },
    {
        name: "Calculated Alarm(14)"
    },
    {
        name: "History"
    }
])

const itemColor = ref([
    {
        color: '#fefefe',
        name: 'openalarm'
    }, {
        color: '#4e95c9',
        name: 'acknow'
    }
])

const diIndex = ref(0)
const dianClick = (index: number) => {
    diIndex.value = index
}

// 组件卸载时清理
onUnmounted(() => {
})

onMounted(() => {
})
</script>

<template>
    <div class="container">
        <div class="con-tab">
            <div class="tabBody">
                <div class="item" :class="diIndex == index ? 'boeff4' : ''" v-for="(item, index) in tabList"
                    @click="dianClick(index)" :key="index">{{ item.name }}</div>
            </div>
            <div class="zhishi">
                <div class="zhishi-item" v-for="(item, index) in itemColor" :key="index">
                    <div class="yanSe" :style="{ background: item.color }"></div>
                    <div class="textColor">{{ item.name }}</div>
                </div>
            </div>
        </div>
        <div class="con-body" v-if="diIndex == 0">
            <stiticCom />
        </div>
        <div class="con-body" v-if="diIndex == 1">
            <Field />
        </div>
        <div class="con-body" v-if="diIndex == 2">
            <Calcult />
        </div>
        <div class="con-body" v-if="diIndex == 3">
            <MHistory />
        </div>
    </div>
</template>

<style scoped lang="scss">
.container {
    
    width: 97%;
    // height: 100%;
    padding-top: 20px;

    .con-tab {
        width: 100%;
        height: 50px;
        display: flex;
        justify-content: space-between;
        .tabBody {
            width: 1000px;
            height: 100%;
            display: flex;
            align-items: center;

            .item {
                width: 240px;
                height: 100%;
                color: #656161;
                display: flex;
                align-items: center;
                justify-content: center;
                cursor: pointer;
            }
        }

        .zhishi {
            width: 320px;
            display: flex;
            justify-content: space-between;
            .zhishi-item{
                display: flex;
                width: 140px;
                align-items: center;
                .yanSe{
                    width: 40px;
                    height: 5px;
                    background-color: #fefeff;
                    margin-right: 10px;
                }
            }
        }
    }
    .con-body{
        width: 100%;
        .con-body-1{
            width: 100%;
            height: 400px;
            background-color: #1c2028;
        }
    }
}

.boeff4 {
    background-color: #1c2028;
    color: #ffffff !important;
    font-weight: bold;
}
</style>
